<template>
  <div class="tree-hole-container">
    <ol class="tree-hole-list">
      <li
        class="tree-hole-li"
        v-for="(treeHole, index) in treeHoleList"
        :key="index"
      >
        <div
          class="tree-hole-content"
          :class="{
            leftTreeHole: index % 2 === 0,
            rightTreeHole: index % 2 !== 0,
          }"
        >
          <img
            shape="square"
            class="avatar-img"
            width="36"
            height="36"
            :src="avatar"
          />
          <div
            class="tree-hole-box"
            :style="{
              background: tree_hole_color[index % tree_hole_color.length],
            }"
          >
            <div
              class="box-tag"
              v-if="index % 2 === 0"
              :style="{
                'border-color':
                  'transparent transparent transparent ' +
                  tree_hole_color[index % tree_hole_color.length],
              }"
            ></div>
            <div
              class="box-tag"
              v-if="index % 2 !== 0"
              :style="{
                'border-color':
                  'transparent ' +
                  tree_hole_color[index % tree_hole_color.length] +
                  ' transparent transparent',
              }"
            ></div>
            <div class="my-content" v-html="treeHole.content"></div>
            <div style="display: flex; justify-content: space-between">
              <div>😃 {{ treeHole.createTime }}</div>
            </div>
          </div>
        </div>
      </li>
    </ol>
    <div class="tree-hole-go">
      <i class="fa fa-paper-plane"></i>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { markRaw, ref } from "vue";
import { WeiYanVo } from "@/types/love";
import { getUserCache } from "@/utils/storage";
const treeHoleList = ref<WeiYanVo[]>([
  {
    id: "1575",
    userId: "1",
    likeCount: 0,
    content:
      "平衡快乐与悲伤\n\n佛曰：一个人只有一个心脏，却有两个心房。一个住着快乐，一个住着悲伤，不要笑得太大声，不然会吵醒旁边的悲伤。\n\n我说：不要太过悲伤，不然会忘记快乐的模样。",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2023-09-05 15:58:49",
  },
  {
    id: "1561",
    userId: "1",
    likeCount: 0,
    content: "争名夺利几时休？早起迟眠不自由。",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2023-09-02 20:43:40",
  },
  {
    id: "668",
    userId: "1",
    likeCount: 0,
    content: "查看端口占用：\n\nnetstat -tunlp | grep 80\nps -ef | grep java",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2023-02-23 13:58:44",
  },
  {
    id: "99",
    userId: "1",
    likeCount: 0,
    content:
      "你看对面的青山多漂亮[微笑]\n<Sara,https://file.poetize.cn/commentPicture/Sara11668261084260789>",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2022-11-12 21:51:29",
  },
  {
    id: "73",
    userId: "1",
    likeCount: 0,
    content:
      "MySQL死锁解决办法\n\n1. 查看事务信息：SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX\n2. 定位到死锁线程：trx_mysql_thread_id\n3. 删除死锁：kill trx_mysql_thread_id",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2022-11-04 10:24:39",
  },
  {
    id: "72",
    userId: "1",
    likeCount: 0,
    content: "回退本地提交到暂存区：git reset --soft HEAD~1",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2022-11-04 10:22:57",
  },
  {
    id: "62",
    userId: "1",
    likeCount: 0,
    content: "2022年8月21日\n\n博客终于完结了。",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2022-08-21 12:13:11",
  },
  {
    id: "9",
    userId: "1",
    likeCount: 0,
    content:
      "今天看B站一个视频，真是豁然开朗。\n\n我们懂得很多道理，但还是过不好这一生。\n\n自认为自己懂得很多道理，然而并没有什么改变。原来无关道理对错，真正重要的是经历。\n\n有了经历，道理才有了意义。",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2022-06-20 15:31:34",
  },
  {
    id: "1",
    userId: "1",
    likeCount: 0,
    content: "网站上线啦[呲牙][呲牙][呲牙]",
    isPublic: true,
    type: "friend",
    source: null,
    createTime: "2021-11-24 13:23:45",
  },
]);
const user = getUserCache();
const avatar = ref(user.avatar);
const tree_hole_color = markRaw([
  "rgb(180, 224, 255)",
  "rgb(180, 203, 255)",
  "rgb(246, 223, 255)",
  "rgb(255, 214, 198)",
  "rgb(131, 123, 199)",
  "#23d5ab",
]);
</script>

<style scoped>
.tree-hole-container {
  padding: 20px;
  margin: 0 auto;
}

.tree-hole-list {
  padding: 100px 0 20px;
  margin: 0;
  position: relative;
  list-style: none;
}

.tree-hole-list:before {
  content: "";
  width: 4px;
  border-radius: 50%;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  background-color: orange;
}

.tree-hole-list:after {
  content: "";
  width: 12px;
  height: 12px;
  border: 4px solid #ff416c;
  border-radius: 50%;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #fff;
  animation: weiYanShadowFlashing 1.5s linear infinite;
}

.tree-hole-li {
  margin: 5px auto;
}

.tree-hole-content {
  position: relative;
  width: 50%;
}

.leftTreeHole {
  text-align: right;
}

.rightTreeHole {
  margin-left: 50%;
}

.tree-hole-content:before {
  content: "";
  width: 12px;
  height: 12px;
  border: 4px solid rgb(3, 169, 244);
  border-radius: 50%;
  position: absolute;
  top: 10px;
  background-color: #fff;
}

.leftTreeHole:before {
  right: 0;
  transform: translateX(10px);
}

.rightTreeHole:before {
  left: 0;
  transform: translateX(-10px);
}

.avatar-img {
  position: absolute;
  top: 0;
  transition: all 0.3s ease-in-out;
}

.leftTreeHole .avatar-img {
  right: 25px;
}

.rightTreeHole .avatar-img {
  left: 25px;
}

.tree-hole-box {
  font-size: 16px;
  padding: 10px;
  width: 360px;
  border-radius: 5px;
  position: relative;
  letter-spacing: 0.1em;
  font-weight: 400;
  transition: all 0.3s ease-in-out;
  color: #000;
  text-align: left;
  display: inline-block;
}

.leftTreeHole .tree-hole-box {
  margin-right: 90px;
}

.rightTreeHole .tree-hole-box {
  margin-left: 90px;
}

.tree-hole-box:hover,
.avatar-img:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 16px 3px rgba(0, 0, 0, 0.15);
}

.box-tag {
  content: "";
  position: absolute;
  border-style: solid;
}

.leftTreeHole .box-tag {
  right: -10px;
  border-width: 15px 0 5px 10px;
}

.rightTreeHole .box-tag {
  left: -10px;
  border-width: 15px 10px 5px 0;
}

.my-content {
  margin: 0 10px 10px;
  line-height: 30px;
}

.tree-hole-box > div:last-child {
  color: #797979;
  padding: 10px 10px 0;
  border-top: 1px dashed #fff;
  font-size: 14px;
}

.tree-hole-go {
  color: rgb(3, 169, 244);
  font-weight: 700;
  font-size: 25px;
  margin: 20px auto;
  text-align: center;
}

.tree-hole-go i {
  cursor: pointer;
}

.tree-hole-go i:hover {
  animation: scale 1s linear infinite;
}

.tree-hole-delete {
  font-size: 14px;
  cursor: pointer;
}

@media screen and (max-width: 1000px) {
  .tree-hole-box {
    width: calc(100% - 90px);
  }
}

@media screen and (max-width: 600px) {
  .tree-hole-content {
    margin-bottom: 50px;
  }

  .tree-hole-list:after {
    left: 0;
  }

  .tree-hole-list:before {
    left: 0;
  }

  .rightTreeHole {
    margin-left: unset;
  }

  .tree-hole-content {
    width: 100%;
  }
}
</style>
